

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Field;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.hypnus.easyui.util.TagUtil;

public class TestServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//		req.setCharacterEncoding("utf-8");
		HttpSession session = req.getSession();
		// Cookie[] cookies = req.getCookies() ;
//		session.setMaxInactiveInterval(5);
		if (session.isNew()) {
			System.out.println("it is new");
			// System.out.println(cookies.toString() );
		} else {
			System.out.println(" welcome back");
		}
		
		InputStream in = req.getInputStream() ;
		byte[] bytes = new byte[32] ;
		in.read(bytes) ;
		System.out.println(new String(bytes,"GBK").trim());
		// System.out.println(resp.encodeURL("/"));

//		resp.setHeader("cookieff", "abcdefg");
		resp.setCharacterEncoding("utf-8");
		PrintWriter write = resp.getWriter();
		write.write("<html><body><input type=\"text\" value=\"微软>拼音\"><body><html>");
		write.flush();
		write.close();
	}

}
